<?php

use yii\helpers\Html;
use common\core\ActiveForm;

/* @var $this yii\web\View */
/* @var $model backend\models\system\Config */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="config-form">

    <?php $form = ActiveForm::begin([
        'options' => [
            'class'=>"form-horizontal",
            'onkeydown' => "if(event.keyCode==13)return false;",
        ],
        'id' => 'create_update_form',
    ]); ?>

    <div class="panel panel-default">
        <div class="panel-body">
            <div class="row">
                <label class="col-sm-2 control-label"><span class="red">*</span>配置标示名称</label>
                <div class="col-xs-9 col-sm-3">
                    <?=$form->field($model, 'name')->textInput(['class'=>'form-control col-md-2'])->label(false); ?>
                </div>
                <div class="col-xs-9 col-sm-6">
                    <div class="hint-block">通过<span style="color:#ff0000;">Yii::$app->params["web"]["配置标识"]</span>访问</div>
                </div>
            </div>
            <div class="row">
                <label class="col-sm-2 control-label"><span class="red">*</span>配置说明</label>
                <div class="col-xs-9 col-sm-3">
                    <?=$form->field($model, 'title')->textInput(['class'=>'form-control col-md-2'])->label(false);?>
                </div>
            </div>
            <div class="row">
                <label class="col-sm-2 control-label"><span class="red">*</span>配置类型</label>
                <div class="col-xs-9 col-sm-3">
                    <?=$form->field($model, 'type')->selectList(
                        Yii::$app->params['config_type'],
                        ['class'=>'form-control col-md-1 chosen'])->label(false) ?>
                </div>
            </div>
            <div class="row">
                <label class="col-sm-2 control-label"><span class="red">*</span>分组</label>
                <div class="col-xs-9 col-sm-3">
                    <?=$form->field($model, 'group')->selectList(
                        Yii::$app->params['config_group'],
                        ['class'=>'form-control col-md-1 chosen'])->label(false) ?>
                </div>
            </div>

            <div class="row">
                <label class="col-sm-2 control-label"><span class="red">*</span>配置值</label>
                <div class="col-xs-9 col-sm-3">
                    <?= $form->field($model, 'value')->textarea(['rows'=>5],['class' => 'form-inline'])->label(false) ?>
                </div>
                <div class="col-xs-3 col-sm-6">
                    <div class="hint-block">如果为数组或枚举类型，配置格式“项:值”每项之间用换行或逗号隔开</div>
                </div>
            </div>

            <div class="row">
                <label class="col-sm-2 control-label"><span class="red">*</span>选项值</label>
                <div class="col-xs-9 col-sm-3">
                    <?= $form->field($model, 'extra')->textarea(['rows'=>5])->label(false) ?>
                </div>
                <div class="col-xs-9 col-sm-6">
                    <div class="hint-block">如果是枚举型(主要是用来做下拉选项的) 需要配置该项</div>
                </div>
            </div>

            <div class="row">
                <label class="col-sm-2 control-label"><span class="red">*</span>说明文字</label>
                <div class="col-xs-9 col-sm-3">
                    <?=$form->field($model, 'remark')->textInput()->label(false)?>
                </div>
            </div>

            <div class="row">
                <label class="col-sm-2 control-label"><span class="red">*</span>排序</label>
                <div class="col-xs-9 col-sm-3">
                    <?=$form->field($model, 'sort')->textInput(['class'=>'form-control col-md-1'])->label(false)?>
                </div>
                <div class="col-xs-9 col-sm-6">
                    <div class="hint-block">数值越小排序越前</div>
                </div>
            </div>

            <div class="row">
                <label class="col-sm-2 control-label"><span class="red">*</span>状态</label>
                <div class="col-xs-9 col-sm-3">
                    <?= $form->field($model, 'status')->radioList(['1'=>'正常','0'=>'隐藏'])->label(false) ?>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-sm-offset-2 col-sm-10">
            <div class="form-group">
                <?= Html::submitButton('保 存', ['class' => 'btn btn-success btn-lg ajax-post','target-form'=>'form-horizontal']) ?>
            </div>
        </div>
    </div>
    <?php ActiveForm::end(); ?>

</div>

<script language="JavaScript">
    <?php $this->beginBlock(Yii::$app->controller->route) ?>

    jQuery(document).ready(function() {
        highlight_subnav('system/config/index'); //子导航高亮
    });

    <?php
    $this->endBlock();
    $this->registerJs($this->blocks[Yii::$app->controller->route], \yii\web\View::POS_END);
    ?>
</script>
